package com.csy.aservice.controller;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.csy.aservice.entity.Stock;
import com.csy.aservice.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 库存 前端控制器
 * </p>
 *
 * @author xx
 * @since 2025-01-07
 */
@RestController
@RequestMapping("/stock")
public class StockController {

    @Autowired
    private IStockService stockService;

    @RequestMapping("/deStock")
    @Transactional
    public String deStock(){
        stockService.update(new Stock().setStock(40),
                new UpdateWrapper<Stock>().eq("user_id",1));
        stockService.update(new Stock().setStock(0),
                new UpdateWrapper<Stock>().eq("user_id",2));
        System.out.println("-------AAAAAAService");
        Integer a = 1 /0;
        return "-----库存更新成功！";
    }

}
